package top.roadvast.activiti;

import org.activiti.engine.HistoryService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricActivityInstanceQuery;

import java.util.List;

/**
 * @Author 郭泽鹏
 * @Date 2020/6/25 21:10
 * @Version 1.0
 * @Description
 * 需求：
 *      历史数据的查看
 */
public class HistoryQuery {
    public static void main(String[] args) {
        //创建defaultProcessEngine对象
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();

        //创建HistoryService对象
        HistoryService historyService = defaultProcessEngine.getHistoryService();

        //创建historicActivityInstanceQuery对象
        HistoricActivityInstanceQuery historicActivityInstanceQuery = historyService.createHistoricActivityInstanceQuery();

        //查询条件
        historicActivityInstanceQuery.processInstanceId("37501");

        //执行查询
        List<HistoricActivityInstance> list = historicActivityInstanceQuery.list();

        //遍历查询结果
        for (HistoricActivityInstance historicActivityInstance : list) {
            System.out.println(historicActivityInstance);
        }
    }
}
